package com.tensquare.friend.conf;

import com.tensquare.friend.interceptor.JwtInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * @BelongsProject: tensquare_parent
 * @BelongsPackage: com.tensquare.user.conf
 * @Author: yang
 * @CreateTime: 2019-03-12 14:30
 * @Description: ${Description}
 */

/**
 * 拦截器配置类
 */

@Configuration  //声明我是一个配置类
public class InterceptorConfig extends WebMvcConfigurationSupport {
    @Autowired
    private JwtInterceptor jwtInterceptor;

    protected void addInterceptors(InterceptorRegistry registry) {
        //注册拦截器要声明拦截器对象和要拦截的请求
        registry.addInterceptor(jwtInterceptor)
                .addPathPatterns("/**")    //拦截
                .excludePathPatterns("/**/login/**");  //放行
    }
}
